//
//  YMLeaseHeaderView.swift
//  NewVersionDemo
//
//  Created by zeng on 2018/3/16.
//  Copyright © 2018年 youmy. All rights reserved.
//

import UIKit

private let kCellId = "kCellId"

class YMLeaseHeaderView: UIView {

    @IBOutlet weak var collectionView: UICollectionView!
    override func awakeFromNib() {
        super.awakeFromNib()
        autoresizingMask = UIViewAutoresizing()
        self.frame = CGRect(x: 0, y: 0, width: ym_screen_width, height: 275)
        
        collectionView.register(UINib.init(nibName: "YMLeaseHeaderCell", bundle: nil), forCellWithReuseIdentifier: kCellId)
        collectionView.dataSource = self
        collectionView.delegate = self
        
        let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout
        layout.itemSize = CGSize(width: 145, height: 190)
        layout.minimumLineSpacing = 10
        layout.sectionInset = UIEdgeInsetsMake(10, 10, 0, 10)
    }
}

extension YMLeaseHeaderView: UICollectionViewDataSource, UICollectionViewDelegate{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 8
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCellId, for: indexPath) as! YMLeaseHeaderCell
        return cell
    }
}

extension YMLeaseHeaderView {
    class func nibView() -> YMLeaseHeaderView {
        return Bundle.main.loadNibNamed("YMLeaseHeaderView", owner: nil, options: nil)?.first as! YMLeaseHeaderView
    }
}
